<!--
To change this template, choose Tools | Templates
and open the template in the editor.
-->
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="X-UA-Compatible" content="IE=9" />
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>rebuttals of papers</title>
        <link href="style3.css" rel="stylesheet" type="text/css" />
    </head>
    <body>
        <form action ="check-rebuttals.php" method ="get">
            <?php
// Connect to the database
            if (isset($_GET['paper_id'])&&isset($_GET['conference_id'])) {
                $dbLink = mysql_connect('localhost', 'root', "");
                if (!$dbLink) {
                    die("MySQL connection failed");
                }
                $id = $_GET['paper_id'];
                $confID = $_GET['conference_id'];
// Query for a list of all status of papers
                mysql_select_db('mydb');
                $result = mysql_query("SELECT p.paper_id, p.paper_title, a.rebuttal_text, m.first_name, m.last_name
                FROM a_rebuttal_paper a
                INNER JOIN member m
                ON (a.member_id = m.member_id)
                INNER JOIN paper p
                ON (a.paper_id = p.paper_id)
                WHERE p.paper_id = {$id}");
// Check if it was successfull
                if ($result) {
                    $num_results = mysql_num_rows($result);
                    // Make sure there are some rows in the database
                    if ($num_results == 0) {
                        echo '<p align="center">There are no rebuttals asked.</p>';
                    } else {
                        // Print the top of a table
                        echo '<table id="table">
                <tr>
                    <td><b>Author</b></td>
                    <td><b>Paper</b></td>
                    <td><b>Rebuttal</b></td>
                    <td><b>Meta-Reviews</b></td>
                </tr>';
                        //author: aya.elmobayad. added collumn with links for requesting meta reviewers
                        // Print each file
                        while ($row = mysql_fetch_assoc($result)) {
                            echo "
                <tr>
                    <td>{$row['first_name']} {$row['first_name']}</td>
                    <td><a href='viewSubmissions.php?paper_id={$row['paper_id']}'>{$row['paper_title']}</a></td>
                    <td>{$row['rebuttal_text']}</td>
                    <td><a href=\"requestMetaReviewers.php?paper_id={$row['paper_id']}&conference_id={$confID}\">Request Meta-Reviewers</a></td>
                </tr>";
                        }
                        //author: aya.elmobayad. added links for requesting meta reviewers that pass the paper id
                        //of the paper to the next page.
                        // Close table
                        echo '</table>';
                    }
                } else {
                    // if connetion to database failed
                    echo 'Error! SQL query failed:';
                }
// Close the mysql connection
                mysql_close($dbLink);
            } else {
                echo "id was not passed";
            }
            ?>
        </form>
        <script type="text/javascript">
        </script>
    </body>
</html>